package cn.v2tila.rsosa.student.jpa;

import cn.v2tila.rsosa.student.entity.MessageEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author v2tila on 2:49 2019/4/6
 */

public interface MessageJPA extends JpaRepository<MessageEntity, Integer>, JpaSpecificationExecutor<MessageEntity> {
    MessageEntity saveAndFlush(MessageEntity messageEntity);

    @Query(value = "select * from message where (uniqueId= ?1 and contactUniqueId = ?2 ) or (uniqueId= ?2 and contactUniqueId = ?1 )", nativeQuery = true)
    List<MessageEntity> findByUniqueIdAndContactUniqueId(String uniqueId,String contactUniqueId);
}
